package jUnitTests;

import static org.junit.Assert.*;
import org.junit.*;
import huaabdelmartin.*;

public class JourneyTests {

	@Test
	public void testJourneyCost() {
		//journey cost should be cheaper per person for a group with more people 
		try {
			int lessNumberOfPassengers = 1;
			int moreNumberOfPassengers = 2;
			Journey j = new Journey(2015, new Car("AB12 RTE",new Driver("bob","smith","34"),true,5), new Destination("Inverness", 356.0), lessNumberOfPassengers);
			Journey j2 = new Journey(2015, new Car("AB12 RTE",new Driver("bob","smith","34"),true,5), new Destination("Inverness", 356.0), moreNumberOfPassengers);
			Double lessPassengersCost = j.getJourneyCost();
			Double morePassengersCost = j2.getJourneyCost();
			//test that cost per person for smaller-group-cost:larger-group-cost is biggerCost:smallerCost
			assertTrue( (lessPassengersCost * ( moreNumberOfPassengers/lessNumberOfPassengers )) > morePassengersCost );
		
			int lessNumberOfPassengers2 = 2;
			int moreNumberOfPassengers2 = 1;
			Journey j3 = new Journey(2015, new Car("AB12 RTE",new Driver("bob","smith","34"),true,5), new Destination("Inverness", 356.0), lessNumberOfPassengers2);
			Journey j4 = new Journey(2015, new Car("AB12 RTE",new Driver("bob","smith","34"),true,5), new Destination("Inverness", 356.0), moreNumberOfPassengers2);
			Double lessPassengersCost2 = j3.getJourneyCost();
			Double morePassengersCost2 = j4.getJourneyCost();
			//test that cost per person for larger-group-cost:smaller-group-cost is smallerCost:biggerCost
			assertTrue( (lessPassengersCost2 * ( moreNumberOfPassengers2/lessNumberOfPassengers2 )) < morePassengersCost2 );
			
			int group1 = 2;
			int group2 = 2;
			Journey j5 = new Journey(2015, new Car("AB12 RTE",new Driver("bob","smith","34"),true,5), new Destination("Inverness", 356.0), group1);
			Journey j6 = new Journey(2015, new Car("GH14 RDZ",new Driver("emma","gramm","39"),true,5), new Destination("Inverness", 356.0), group2);
			Double group1Cost = j5.getJourneyCost();
			Double group2Cost = j6.getJourneyCost();
			//test that two different cost calculations give same result with same number of passengers and same destination
			assertEquals("These should be equal", group1Cost,group2Cost );
			
		} catch (VehicleRegFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
